<template>
    <el-dialog title="版本信息" :visible.sync="lock" :modal="true" :append-to-body="true"
               :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" center>
        <p>版本: v.0.1.0</p>
        <p>预览版: true</p>
        <p>
            <b>请在网络环境下使用</b>
            可用期：
        </p>
        <p>{{expireDate.s}} ~ {{ expireDate.e}}</p>
    </el-dialog>
</template>

<script>
    export default {
        name: "Preview",
        data() {
            return {
                preview: true,
                lock: true,
                expireDate: {s: '2019-12-7 00:00:00', e: '2019-12-11 23:59:59'},
            }
        },
        created() {
            if (this.preview) {
                this.$axios.get('http://api.k780.com/?app=life.time&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json')
                    .then(response => {
                        let now = new Date(response.data.result.datetime_1).getTime();
                        if (now < new Date(this.expireDate.s).getTime() || now > new Date(this.expireDate.e).getTime()) {
                            this.$utils.AppMessage.error('预览版app已过期');
                        } else {
                            this.lock = false;
                        }
                    });
            } else {
                this.lock = false;
            }
        },
    }
</script>

<style scoped>

</style>